import http from '@/utils/http'

const BASE_URL = '/system/equipment'

export interface EquipmentResp {
  id: string
  name: string
  meetingRoomId: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface EquipmentDetailResp {
  id: string
  name: string
  meetingRoomId: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface EquipmentQuery {
  name: string
  sort: Array<string>
}
export interface EquipmentPageQuery extends EquipmentQuery, PageQuery {}

export interface ChangeEquipmentReq {
  id: number
  name: string
  meetingRoomId: number
}

/** @desc 查询会议终端列表 */
export function listEquipment(query: EquipmentPageQuery) {
  return http.get<PageRes<EquipmentResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询会议终端详情 */
export function getEquipment(id: string) {
  return http.get<EquipmentDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增会议终端 */
export function addEquipment(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改会议终端 */
export function updateEquipment(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除会议终端 */
export function deleteEquipment(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 同步设备 */
export function syncEquipment(data) {
  return http.get(`${BASE_URL}/getequipment`, data)
}

/** @desc 修改终端名称 */
export function updateEquipmentName(data: ChangeEquipmentReq) {
  return http.post(`${BASE_URL}/updateName`, data)
}
